<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <script>
      /*clas继承 原理等于寄生组合
        ES6基于class创造出来的类不能当普通函数执行
        */
      class A {
        constructor(x) {
          this.x = x;
        }
        getX() {
          console.log(this.x);
        }
      }
      class B extends A {
        constructor(y) {
          super(200);
          this.y = y;
        }
        getY() {
          console.log(this.y);
        }
      }
      let b1 = new B(100);
      console.log(b1.y); //100
      console.log(b1.getY()); //会去执行getY
      console.log(b1.x); //100
      console.log(b1.getX()); //会去执行getX
    </script>
  </body>
</html>
